package com.orchard.orchardfarmmanagementsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orchard.orchardfarmmanagementsystem.entity.Materials;
import com.orchard.orchardfarmmanagementsystem.entity.TaskMaterialRelation;
import org.apache.ibatis.annotations.*;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface TaskMaterialRelationMapper extends BaseMapper<TaskMaterialRelation> {

    @Insert("INSERT INTO taskmaterialrelation (task_id, material_id, required_quantity) VALUES (#{taskId}, #{materialId}, #{quantity})")
    void insertTaskMaterialRelation(@Param("taskId") Integer taskId,
                                    @Param("materialId") Integer material_id,
                                    @Param("quantity") Integer quantity);

    @Select("SELECT material_id, required_quantity FROM taskmaterialrelation WHERE task_id = #{taskId}")
    List<TaskMaterialRelation> getMaterialsByTaskId(@Param("taskId") Integer taskId);
}